#pragma once
#include "Hash_table.h";


namespace ssy
{
	template<class K, class T>
	class unordered_map
	{
		struct KOfT
		{
			K operator()(const pair<const K, T>& x)
			{
				return x.first;
			}
		};

	public:
		typedef typename ssy::hash_table<K, pair<const K, T>, KOfT>::iterator iterator;
		typedef typename ssy::hash_table<K, pair<const K, T>, KOfT>::const_iterator const_iterator;

		iterator begin()
		{
			return _ht.begin();
		}

		iterator end()
		{
			return _ht.end();
		}

		const_iterator begin() const
		{
			return _ht.begin();
		}

		const_iterator end() const
		{
			return _ht.end();
		}

		pair<iterator, bool> insert(const pair<const K, T>& data)
		{
			return _ht.insert(data);
		}

		T& operator[](const K& key)
		{
			pair<hash_table<K, pair<const K, T>, KOfT>::iterator, bool> ret = _ht.insert(make_pair(key,T()));
			return ret.first->second;
		}

	private:
		hash_table<K, pair<const K, T>,KOfT> _ht;
	};
}